UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'f9xDreg4iQAYnG6gBQMBOCkYh9uf146f5ZWA+H6ydP0='
WHERE
key_id = 'caef63b53743f63a4b51555add9121597f6b88a3fde83f363b0f4be348a4546c'
AND (
token = 'f9xDreg4iQAYnG6gBQMBOCkYh9uf146f5ZWA+H6ydP0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)