UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'NE7YjxNvHiQS3HTpdN+x9tbZ7rf7oG3U3cg887f3+W0='
WHERE
key_id = '6470e0714e2b6374ea432e3bebfb9c6b33330e44d4d9ac91f29829fc1b04640b'
AND (
token = 'NE7YjxNvHiQS3HTpdN+x9tbZ7rf7oG3U3cg887f3+W0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)