UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'avTRgtQDZnnACLXMhIEiX88yBZyrwFISzSGwOWWKohQ='
WHERE
key_id = '877446039935cfcc7f62ed1c5a66b8f50a71e697b65548997fbf425031abb331'
AND (
token = 'avTRgtQDZnnACLXMhIEiX88yBZyrwFISzSGwOWWKohQ='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)