UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '9Bc1CsC7SI7URcyXbxYxcn6bpoOKnzvXyiYpZABqjCw='
WHERE
key_id = 'a490204d647455d7ff22e8b6d8624b12caf0ee2a8da670f009c6e576d0af38ac'
AND (
token = '9Bc1CsC7SI7URcyXbxYxcn6bpoOKnzvXyiYpZABqjCw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)