UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'p8OgoRYhTuCqSNY1YREiYItrBu/xA9LlXH/NfyKG2Dk='
WHERE
key_id = 'b38645d81988b7e9f231949b1a0b2be8d3e6425670ce0f5c19025821286e2842'
AND (
token = 'p8OgoRYhTuCqSNY1YREiYItrBu/xA9LlXH/NfyKG2Dk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)