UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'qrqhtv1+qQJGNZQGRYz3BMEBax+EdJtY4n7l3f6xi18='
WHERE
key_id = 'a7a47f8c743ceec4b2ea164f74c78fdf2e50ee2bf27a5e03017df8051de310fc'
AND (
token = 'qrqhtv1+qQJGNZQGRYz3BMEBax+EdJtY4n7l3f6xi18='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)