UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'rssdUsk+46Z7wMAUE+iL5hrRmqiS1Ioh8E51RupvuwE='
WHERE
key_id = 'af409377f055cb3aabd138397ffc613cd65527311efcbbe12d067c40d7a2addb'
AND (
token = 'rssdUsk+46Z7wMAUE+iL5hrRmqiS1Ioh8E51RupvuwE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)