UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'XgJ4hZzY37NfIkXaEFNLqhF3IyK7XHDIC1KIVLDcw+U='
WHERE
key_id = 'e4591572af150f0615c4ce7ccbdc66c0122183463cd46a4214726776ba98999a'
AND (
token = 'XgJ4hZzY37NfIkXaEFNLqhF3IyK7XHDIC1KIVLDcw+U='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)