UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'EuSnQFSiv7bcTVMEP0iA8yLkeexdgfpcIelH9es7dN4='
WHERE
key_id = 'a8b0fa1e5d4d4c632a3c9a3de47cf58a139165a6d717cc6b6a3230153b89a518'
AND (
token = 'EuSnQFSiv7bcTVMEP0iA8yLkeexdgfpcIelH9es7dN4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)