UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'k46Ci4hlxKsxE8lK7EERc8LnaLBLJMFIkMjIUB5tywc='
WHERE
key_id = '40fc8dc1a31988e65a7c755227cca2912fa77fecea75a88117a65d9f1c3b9bea'
AND (
token = 'k46Ci4hlxKsxE8lK7EERc8LnaLBLJMFIkMjIUB5tywc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)