UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'lKydPJ4OG5XxdPE6Gi5VVTzRnJyfze2QcAaYy49IHOU='
WHERE
key_id = 'b115e4c49dc6b6a079973a9cda71b70f6d441a35998c2ca70a2045cade852357'
AND (
token = 'lKydPJ4OG5XxdPE6Gi5VVTzRnJyfze2QcAaYy49IHOU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)