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