UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Tp65D3OPC1iMTrieafzoBi2VIjiz+Hh7jL3SK9dh6n4='
WHERE
key_id = 'c01781c1e88f910edae225eb0833bb31ab248203c850f974b34f24be8ab9937e'
AND (
token = 'Tp65D3OPC1iMTrieafzoBi2VIjiz+Hh7jL3SK9dh6n4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)