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