UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'c1FYoZE+2EFmLnOciRvKXarm+QNnNcyjG/RkoRtrh+Y='
WHERE
key_id = 'd51240c5cc4ed869ea2599f2a776f189015e4074f054a9eff6e80f6ed6e87fb8'
AND (
token = 'c1FYoZE+2EFmLnOciRvKXarm+QNnNcyjG/RkoRtrh+Y='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)