UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'B1snKThLle6IwAEGmUeWHrpDH+9h4Aw+OLBW0UHX3gA='
WHERE
key_id = 'd82b6f00667c86e9b812ed815b4b556d4aac979004473627ac9bf4f888cde48f'
AND (
token = 'B1snKThLle6IwAEGmUeWHrpDH+9h4Aw+OLBW0UHX3gA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)