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