UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'rsa9MY9F9nfcBjhIKLN7GafbSdf8XX1ZChxs23+17S0='
WHERE
key_id = '27f9ac8b3874d17bf81b0c2050fd2667cc15d106b5e9917541dc3fe38919eee1'
AND (
token = 'rsa9MY9F9nfcBjhIKLN7GafbSdf8XX1ZChxs23+17S0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)