UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'X+JNHqxkOMQY1NWK97nG0oQ3/d6g8CDYmWRySAHa4+A='
WHERE
key_id = '245f6c7cf4644c1786a91e9641e397f9896525692727c1543b1e7c67686b89f0'
AND (
token = 'X+JNHqxkOMQY1NWK97nG0oQ3/d6g8CDYmWRySAHa4+A='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)