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