UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'bcWt3V+FCFRBfgS+Lk2tUlcVxslccmR8tBPmcGd5xwM='
WHERE
key_id = '787fea1fc21f2b40e2b40b58edc00589b213cc17085526e66d6edc4fbf912312'
AND (
token = 'bcWt3V+FCFRBfgS+Lk2tUlcVxslccmR8tBPmcGd5xwM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)