UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KAMt6ctgC6nAd31dbu2BYMZuASnQ694Zn+JTCSBgVcc='
WHERE
key_id = 'b5535716102537a83e6a866482e70ab1bdbdf608721da9ab2239dfdee792bc26'
AND (
token = 'KAMt6ctgC6nAd31dbu2BYMZuASnQ694Zn+JTCSBgVcc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)